package com.lovo.commodity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.commodity.dao.ICommodityDAO;
import com.lovo.commodity.service.ICommodityService;
import com.lovo.common.bean.CommodityBean;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author bdk
 * @since 2021-03-10
 */
@Service
@GlobalTransactional(rollbackFor = Throwable.class)
public class CommodityServiceImpl extends ServiceImpl<ICommodityDAO, CommodityBean> implements ICommodityService {
    @Resource
    private ICommodityDAO commodityDAO;
    @Override
    public void updateStock(Long commId) {
        CommodityBean commodityBean = commodityDAO.selectById(commId);
        commodityBean.setCommStock(commodityBean.getCommStock() - 1);
        commodityDAO.updateById(commodityBean);
    }
}
